package disjunction.examples.states
{
	import disjunction.Controller;
	import disjunction.ControllerConfig;
	import disjunction.Game;
	import disjunction.GameState;
	import disjunction.View;
	import disjunction.ViewConfig;
	import disjunction.extensions.input.KeyboardManager;
	import disjunction.extensions.view.BlitterViewConfig;
	import disjunction.state.*;
	
	import flash.geom.Point;
	
	[SWF(width="640", height="480", backgroundColor="#000000", frameRate="50")]
	
	/**
	 * States Example.
	 *
	 * @author Nick Wiggill
	 */
	
	public class Main extends Game
	{
		public const LOGIC_PERIOD_MS:uint = 25;
		public const VIEW_PERIOD_MS:uint = 25;
		public const UPDATE_TIMEOUT_MS:uint = 500;
		public const WIDTH:Number = 320;
		public const HEIGHT:Number = 200;
		public const SCALE:Number = 2;
		
		public function Main()
		{
			var states:Vector.<State> = new Vector.<State>();
			states.push(	new GameState("Menu"),
							new GameState("Play"),
							new GameState("Scoreboard")	);
			
			//prepare config for starting state
			var config:GameStateConfig = new GameStateConfig();
		
			config.model = //new PlayModel();
			{ 
				levelParams: new LevelParameters(), //already configured, eg. in menu?
				keysDown: {}
			};
			
			var screenConfig:ViewConfig = new BlitterViewConfig
			(
				VIEW_PERIOD_MS, 
				UPDATE_TIMEOUT_MS,
				new PlayViewStrategy(),
				this,
				WIDTH,
				HEIGHT,
				SCALE
			);
			
			//config.views.push(screenConfig);//, logConfig);
			config.view = screenConfig;
			
			config.controller = new ControllerConfig
			(
				LOGIC_PERIOD_MS,
				UPDATE_TIMEOUT_MS,
				new PlayControlStrategy()
				//physics: new Box2DConfig(PHYSICS_ITERATIONS)
			);
			
			addChild(new KeyboardManager(config.model.keysDown));
			
			initialise("Menu", states, config);
		}
	}
}